CheckBoxList.inherit("Control");

function CheckBoxList(listId, list, isEnabled){
	var checkBoxList=document.getElementById(listId);
	var grid=list;
	this.enabled = isEnabled
	if (grid==null) return;
	if (grid.tagName=="TABLE") {
		this.table=grid;
	} else {
		this.table=grid.getElementsByTagName("TABLE")[0];
	}
}

CheckBoxList.prototype.markAll=function () {
    if (!this.enabled) return;
    if (!Utils.isDefined(this.table)) return;
	for(var i=0;i<this.getRowCount();i++){
		var control = this.getCellControl(i, 0);
		if (Utils.isDefined(control))
    		control.checked = true;
	}
}

CheckBoxList.prototype.unmarkAll=function () {
    if (!this.enabled) return;
    if (!Utils.isDefined(this.table)) return;
	for(var i=0;i<this.getRowCount();i++){
		var control = this.getCellControl(i, 0);
		if (Utils.isDefined(control))
    		control.checked = false;
	}
}

CheckBoxList.prototype.getRowCount = function () {
    if (this.table==null||this.table.rows==null) return 0;
    return this.table.rows.length;
}

CheckBoxList.prototype.getCellControl = function (row, col) {
	return this.table.rows[row].cells[col].getElementsByTagName("INPUT")[0];
}



